package com.jianying.day03;

import org.apache.flink.api.common.eventtime.WatermarkStrategy;
import org.apache.flink.connector.file.src.FileSource;
import org.apache.flink.connector.file.src.reader.TextLineInputFormat;
import org.apache.flink.core.fs.Path;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * ClassName: Flink05_Source_File
 * Package: com.atguigu.day03
 * Description:
 *
 * @Author: tubage
 * @Create: 2024/4/1 11:10
 * @Version: 1.0
 */
public class Flink05_Source_File {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

//        DataStreamSource<String> fileDS = env.readTextFile("/Users/china/Atguigu/05_Code/bigdata-flink/input/word.txt");

        FileSource<String> source = FileSource.
                forRecordStreamFormat(new TextLineInputFormat(),
                        new Path("C:\\MyFiles\\Project\\bigdata_flink\\input\\word.txt"))
                .build();
        // TODO 将指定的数据源封装为流
//        env.addSource(); // 1.12之前
        DataStreamSource<String> fileDS = env.fromSource(source, WatermarkStrategy.noWatermarks(), "fileSource");// 1.12之后

        fileDS.print();
        env.execute();
    }
}
